﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RepositoryFramework.Validators;
using FluentValidation;
using AutoMapper;

namespace Portal.Logic.Validators
{
	/// <summary>
	/// Class <see cref="BaseValidator"/> define base validator
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public abstract class BaseValidator<T> : AbstractValidator<T>
	{
		#region Methods

		/// <summary>
		/// Validates the specified entity.
		/// </summary>
		/// <param name="entity">The entity.</param>
		/// <returns></returns>
		public new IValidationResult Validate(T entity)
		{
			var result = base.Validate(entity);
			if (result != null)
			{
				return result.MapNew<FluentValidation.Results.ValidationResult, ValidationResult>();
			}
			return null;
		}

		#endregion
	}
}
